package com.dengqi.mymodule.activity.unittest;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Created by dell on 2019/2/21
 */
public class SharedPreferencesHelper {

    private Context mContext;
    private SharedPreferences sharedPreferences;

    public SharedPreferencesHelper(Context context) {
        mContext = context;
        sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
        //也可以自定义name
//        sharedPreferences = mContext.getSharedPreferences("name", Context.MODE_PRIVATE);
    }

    public void saveValue(String key, String value) {
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.apply();
    }

    public String loadValue(String key) {
        return sharedPreferences.getString(key, "");
    }

}
